package Covid2;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class Covid2Driver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf,"Covid2");

        job.setJarByClass(Covid2Driver.class);
        job.setMapperClass(Covid2Mapper.class);
        job.setReducerClass(Covid2Reducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(CovidBean.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(CovidBean.class);


        Path input = new Path("inputdata7");
        Path output = new Path("outputdata7");

        FileSystem fs = FileSystem.get(conf);
        if (fs.exists(output))
        {
            fs.delete(output, true);
        }
        FileInputFormat.setInputPaths(job,input);
        FileOutputFormat.setOutputPath(job,output);

        boolean result = job.waitForCompletion(true);

        System.exit(result?0:1);
    }
}
